package com.ruoyi.quality.controller;


import com.ruoyi.common.core.domain.R;
import com.ruoyi.quality.domain.dto.SamplingDto;
import com.ruoyi.quality.service.SamplingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;

@RestController
@RequestMapping("/sampling")
public class SamplingController {

    @Autowired
    SamplingService samplingService;


    @PostMapping("/getSamplingByPage")
    public R export(@RequestBody SamplingDto materialDto)
    {
        return R.ok(samplingService.getSamplingByPage(materialDto));
    }

    @PostMapping("/addSampling")
    public R addTest(@RequestBody SamplingDto materialDto) throws ParseException {
        samplingService.addSampling(materialDto);
        return R.ok("添加成功");
    }

    @PostMapping("/delSampling")
    public R delTest(@RequestBody SamplingDto materialDto){
        samplingService.delSampling(materialDto);
        return R.ok("删除成功");
    }

    @PostMapping("/updateSampling")
    public R updateTest(@RequestBody SamplingDto materialDto){
        samplingService.updateSampling(materialDto);
        return R.ok("锁定成功");
    }


}
